<?php

declare(strict_types=1);

namespace App\Helpers;

/**
 * 短信收发类-创蓝
 * @author ShenWei
 *
 */
class SmsChuanglanUtil
{
    public $accountId = 'Xj70j9sf';
    public $password = 'MXh2TSwH';
    // protected $apiUrl = 'http://smssh1.253.com/msg/variable/json';
    protected $apiUrl = 'https://smssh1.253.com/msg/v1/send/json';

    public function __construct()
    {
    }

    public function send($phone = '', $msg = '')
    {
        if (!$phone) return false;
        $data = [
            'account' => $this->accountId,
            'password' => $this->password,
            'msg' => $msg,
            'phone' => $phone
        ];
        // ksort($data);
        // $data['sign'] = md5(md5(implode('', $data)));
        log_info(__CLASS__ . "==" . json_encode($data));
        return Helper::httpReq($this->apiUrl, $data, 'json');
    }
}
